package com.security.one_way_encry.base64;


import org.bouncycastle.util.encoders.Base64;

/**
 * @ClassName Base64TestByBouncyCastle
 * @Description Bouncy Castle提供的base64编码工具
 * @Detail detail
 * @Author MyPC
 * @Date 2020/9/23
 * @Version 1.0
 */
public class Base64TestByBouncyCastle {

    public static void main(String[] args) {
        String hello = encryptBASE64("hello");
        System.out.println(hello);
        String s = decryptBASE64(hello);
        System.out.println(s);
    }

    public static String encryptBASE64(String key){
        byte[] encode = Base64.encode(key.getBytes());
        return new String(encode);
    }

    public static String decryptBASE64(String code){
        byte[] decode = Base64.decode(code);
        return new String(decode);
    }
}
